<template>
	<view>
		<!-- 授权弹窗 -->
		<block v-if="isUser==1">
			<view class="authorize_box">
				<view class="ar_box">
					<view class="ar_word">
						<view class="ar_tit">温馨提示</view>
						<view class="ar_cont">请授权以便您更好的体验此小程序</view>
					</view>
					<view class="ar_butt_box">
						<view class="ar_butt_item ar_line" @tap="qxsq_butt">取消</view>
						<view class="ar_butt_item">
							确定
							<button open-type="getUserInfo" @getuserinfo="getUser"></button>
						</view>
					</view>
				</view>
			</view>
		</block>
		<view class="serch_view" v-if="area_set==1">
			<view class="serch_border_area">
				<!-- <block wx:if="{{is_sq==0}}">
			<label class="sq_lab" bindtap="getUserLocation">未授权</label>
		</block> -->
				<!-- <block wx:if="{{is_sq==1}}"> -->
			<!-- 	<region-picker @change="bindRegionChange" class="serch_border_area_border" :customItem="customItem"
					:value="region">
					<view class="picker">
						{{region[2]?region[2]:region[1]?region[1]:region[0]?region[0]:'全国'}}
					</view>
					<view class="picker">
						{{region[2]?region[2]:region[1]?region[1]:region[0]?region[0]:'全国'}}
					</view>
				</region-picker> -->
				<view class="serch_border_area_border" @click="showUniAddressSelector = true">
					<view class="picker">
						{{areaInfo.length ? areaInfo[areaInfo.length - 1] : "全国" }}
					</view>
				</view>
				<image class="serch_border_area_img" src="/static/pages/image/dingweixjt_btn.png"></image>
				<!-- </block> -->
			</view>
			<view class="serch_border1">
				<image class="serch_border_img" src="/static/pages/image/sousuo_btn.png"></image>
				<view @tap="search" class="serch_border_text" placeholder
					placeholderStyle="font-size: 24rpx;color: #B2B2B2;" type="text">请输入搜索内容　　 　如 卡特</view>
			</view>
		</view>
		<view class="serch_view" v-if="area_set==2">
			<view class="serch_border">
				<image class="serch_border_img" src="/static/pages/image/sousuo_btn.png"></image>
				<view @tap="search" class="serch_border_text" placeholder
					placeholderStyle="font-size: 24rpx;color: #B2B2B2;" type="text">请输入搜索内容</view>
			</view>
		</view>
		<view class="serch_border_nav"></view>
		<!-- <swiper autoplay="{{autoplay}}" class="scroll_size" duration="{{duration}}" indicatorActiveColor="#fff" indicatorDots="{{indicatorDots}}" interval="{{interval}}" lazyLoad="{{true}}">
	<swiper-item bindtap="banner" data-id="{{item.product_id}}" data-type="{{item.type}}" wx:for="{{banner}}" wx:key="1">
		<image class="scroll_size" mode="scaleToFill" src="{{item.img_patch}}" style="width:100%"></image>
	</swiper-item>
</swiper> -->
		<view class="xiaoxi">
			<view class="xiaoxi_zhezhao"></view>
			<image class="xiaoxi_leftImg" src="/static/pages/image/xiaoxi_btn.png"></image>
			<swiper :autoplay="autoplay" :circular="true" class="update_scroll_modle" duration="1500"
				:indicatorDots="false" interval="2000" :vertical="true">
				<swiper-item v-for="(item, index) in textJson" :key="index" style="color:#F75F5F">
					{{item.content}}
				</swiper-item>
			</swiper>
			<view @tap="info_notice" class="xiaoxi_right_btn">详情</view>
		</view>
		<view v-if="recom==1&&home_arr.length>0">
			<view class="shangjia_solid_modle_scroll_title">推荐门店</view>
			<scroll-view class="shangjia_solid_modle_scroll" scroll-x="true">
				<view v-for="(item, index) in home_arr" :key="index" class="shangjia_solid_modle_scroll_modle">
					<image @tap="store" class="shangjia_solid_modle_scroll_modle_img" :data-uid="item.uid"
						mode="aspectFill" :src="item.head_image"></image>
					<view class="shangjia_solid_modle_scroll_modle_title">{{item.nickname}}</view>
					<view class="shangjia_solid_modle_scroll_modle_price">平台推荐
						<image class="shangjia_solid_modle_scroll_modle_priceimg"
							src="/static/pages/image/zuanshi_icn.png"></image>
					</view>
				</view>
			</scroll-view>
		</view>
		<view @tap="guanggao" class="guanggao_view" v-if="unitid!=123">
			<ad :unitId="unitid"></ad>
		</view>
		<!-- 分类导航 -->
		<view class="cla_nav">
			<block v-for="(item, index) in navData" :key="index" v-if="now_status==0">
				<view class="nav_item" @tap="click_topNav" :data-name="item.name" :data-cid="item.id"
					:data-id="item.type">
					<view class="img_box">
						<image mode="aspectFit" :src="webUrl + '' + item.img"></image>
					</view>
					<view class="nav_word">{{item.name}}</view>
				</view>

			</block>
			<view class="clear"></view>
		</view>

		<!-- 买卖设备 -->
		<view class="buse_box">
			<view class="tit_box">
				<view @tap="toMMPage" class="tit_word tit_col" data-index="0">买设备</view>
				<view @tap="toMMPage" class="tit_word" data-index="1">卖设备</view>
			</view>
			<view class="clear"></view>
			<!-- <view class="condition_box">
		<block wx:for="{{allClass}}" wx:key="key" wx:for-item="allItem">
			<view wx:for="{{allItem}}" class="cond_item" data-type="{{item.type}}" data-name="{{item.name}}" data-id="{{item.id}}" bindtap="toSeeDetList">{{item.name}}</view>
		</block>

	</view> -->
			<view class="clear"></view>
			<button class="buse_butt" @tap="click_toDET">查看全部车源</button>
		</view>
		<!-- 热门机型 -->
		<view class="hot_box" style="display:none;">
			<view class="hline"></view>
			<view class="h_tit">热门机型</view>
			<view class="hot_list">
				<view v-for="(item, index) in hotList" :key="index" class="hot_item" @tap="detile" :data-id="item.id">
					<view class="hot_tit">{{item.name}}</view>
					<view class="hot_img">
						<image mode="aspectFill" :src="item.carimg"></image>
					</view>
				</view>
				<view class="clear"></view>
			</view>
		</view>
		<view :class="'shop_view ' + (brand_show||active_index||sort_show?'shop_view_active':'')">
			<view class="new_tit">最新好车</view>
			<view class="nav" style="display:none;">
				<view @tap="active_nav" :class="'nav_modle ' + (active_index==5?'nav_modle_active':'')"
					data-active_index="5">排序
					<image class="nav_modle_img"
						:src="'../image/' + (active_index==5?'lvsejtxs_btn.png':'xiajiantou_btn.png')"></image>
				</view>
				<view @tap="market_brand" :class="'nav_modle ' + (active_index==2?'nav_modle_active':'')"
					data-active_index="2">品牌
					<image class="nav_modle_img"
						:src="'../image/' + (active_index==2?'lvsejtxs_btn.png':'xiajiantou_btn.png')"></image>
				</view>
				<view @tap="car_yer" :class="'nav_modle ' + (active_index==3?'nav_modle_active':'')"
					data-active_index="3">年限
					<image class="nav_modle_img"
						:src="'../image/' + (active_index==3?'lvsejtxs_btn.png':'xiajiantou_btn.png')"></image>
				</view>
				<view @tap="market_class" :class="'nav_modle ' + (active_index==1?'nav_modle_active':'')"
					data-active_index="1">分类
					<image class="nav_modle_img"
						:src="'../image/' + (active_index==1?'lvsejtxs_btn.png':'xiajiantou_btn.png')"></image>
				</view>
				<view @tap="car_detail" :class="'nav_modle ' + (active_index==4?'nav_modle_active':'')"
					data-active_index="4">价格
					<image class="nav_modle_img"
						:src="'../image/' + (active_index==4?'lvsejtxs_btn.png':'xiajiantou_btn.png')"></image>
				</view>
			</view>
			<view class="choose_view">
				<view v-for="(item, index) in search_arr" :key="index" @tap="clone" class="choose_view_modle"
					:data-index="index">{{item.check_name}}
					<image class="choose_view_modle_img" src="/static/pages/image/clone.png"></image>
				</view>
			</view>
			<view v-if="active_index!=0&&!brand_show">
				<view class="nav_fenlei">
					<view
						:class="'nav_fenlei_modle ' + (car_class!=''&&active_index==1||car_km!=''&&active_index==4||car_year!=''&&active_index==3?'':'nav_fenlei_modle_active')">
						不限</view>
					<view v-for="(item, index) in car_type" :key="index" @tap="carListFun"
						:class="'nav_fenlei_modle ' + (check_name==item.name||car_km==item||car_year==item?'nav_fenlei_modle_active':'')"
						:data-id="item.id" :data-index="index" :data-km="item" :data-name="item.name" :data-year="item">

						{{active_index==3?item:''}} {{active_index==4?item:''}}
						{{active_index!=4&&active_index!=3?item.name:''}}

					</view>
				</view>
				<view @tap="can_1" class="nav_fenlei_mengceng"></view>
			</view>
			<view v-if="sort_show">
				<view class="nav_fenlei">
					<view v-for="(item, index) in sortArr" :key="index" @tap="sort_car"
						:class="'paixu_modle  ' + (sort_id==index?'paixu_modle_active':'')" :data-index="index">{{item}}
						<image class="paixu_modle_img" src="/static/pages/image/duihao_icn.png" v-if="sort_id==index">
						</image>
					</view>
				</view>
				<view @tap="can_1" class="nav_fenlei_mengceng" style="background:rgba(0,0,0,0.10)"></view>
			</view>
			<view class="choose_area" v-if="brand_show">
				<view class="pinpai_over">
					<view v-for="(item, index) in car_type" :key="index" @tap="carListFun" class="choose_area_modle"
						:data-id="item.id" :data-index="index" :data-name="item.name">
						<image class="choose_area_modle_img" :src="item.brand_icon"></image>
						<view class="choose_area_modle_title">{{item.name}}</view>
					</view>
				</view>
				<view @tap="can_1" class="nav_fenlei_mengceng"></view>
			</view>
			<view class="shop_border">
				<view v-for="(item, indexs) in carList" :key="indexs" class="shop_modle" v-if="plate_type==1">
					<view class="shop_modle_headImg_view">
						<image @tap="store" class="shop_modle_headImg" :data-uid="item.uid" :src="item.head_image">
						</image>
						<view class="shop_modle_headImg_view_btmTextView" v-if="item['top_status']">推荐</view>
					</view>
					<view class="shop_modle_right">
						<view @tap="detile" :data-id="item.id">
							<view class="shop_modle_right_title">
								<text
									class="shop_modle_right_title_name">{{item.usersname?item.usersname:item.username}}</text>
								<text class="ziying" v-if="item.uid==0">自营</text>
								<text class="ziying" v-if="item.is_vip==1">认证车商</text>
								<text class="shop_modle_right_title_right">{{item.price}}万</text>
							</view>
							<view class="shop_modle_message">
								<text class="zhuanrang"></text>【{{item.name}}】 {{item.km}}万公里 {{item.year}}
							</view>
							<view class="shop_modle_area">
								<text
									class="shop_modle_area_dian">·</text>{{item.timestr}}·{{item.caraddress!='undefined'?item.caraddress:''}}
							</view>
						</view>
						<scroll-view class="solid_modle_scroll" scroll-x="true">
							<view v-for="(item, index) in item['image']" :key="index" class="solid_modle_scroll_modle">
								<image @tap="previewImage" class="solid_modle_scroll_modle_img" :data-index="indexs"
									:data-src="item.img_patch" mode="aspectFill" :src="item.img_patch"></image>
							</view>
						</scroll-view>
						<view class="shop_modle_num">
							浏览{{item.browse}}
							<text style="float:right" v-if="item.y>0&&item.x>0&&latitude>0&&longitude>0">
								{{item.distance}}km
							</text>
						</view>
					</view>
				</view>
				<view v-for="(item, indexs) in newList" :key="indexs" class="modle" v-if="plate_type==2">
					<view class="tuijian" v-if="item['top_status']">推荐</view>
					<view class="timg_box" @tap="detile" :data-id="item.id">
						<image class="modle_img" mode="aspectFill" :src="item.carimg"></image>
						<image v-if="item.video!=''" class="bf_img" mode="aspectFill"
							:src="webUrl + 'addons/monai_market/static/wimgs/bofang.png'"></image>
					</view>

					<view @tap="detile" class="message_border" :data-id="item.id">

						<image v-if="item.status==2" class="sell_img" src="/static/pages/image/sell.png"></image>

						<view class="modle_name_conetnt">
							<!-- <view class="ziying" wx:if="{{item.is_vip==1}}">认证车商</view>
                    <view class="ziying" wx:if="{{item.uid==0}}">自营</view> -->
							<text class="modle_name">{{item.name}}</text>
							<view class="pri_butt">联系电话</view>
							<!-- {{item.year}}  {{item.exhaust}} 
          {{item.gearbox==0?'手自一体':''}}{{item.gearbox==1?'手动档':''}}{{item.gearbox==2?'自动档':''}} -->
						</view>
						<view class="modle_chexing"> {{item.buydate}} | {{item.province}}-{{item.city}}
							<!-- <text style="float:right" wx:if="{{item.y>0&&item.x>0&&latitude>0&&longitude>0}}">{{item.distance}}km</text> -->
						</view>
						<view class="modle_price">
							<view class="pri_num">{{item.price}}万 首付{{getPayment(item.price)}}万</view>
							<!-- <view class="pri_num">{{item.price}}万</view> -->
						</view>
						<!-- 	<view class="pri_butt1">{{item.has_invoice!=0?'有发票':item.has_certificate!=0?'有合格证':'无发票、合格证'}}
						</view> -->

					</view>
				</view>
				<view class="end_none" v-if="scanReachBottom">没有更多了...</view>
				<view class="btm_nav"></view>
			</view>
		</view>
		<new-order />
		
		<UniAddressSelector
		    v-if="showUniAddressSelector"
		    :areaInfoSelected="areaInfoObj"
		    @cancel="handleCancel"
		    @confirm="handleConfirm">
		</UniAddressSelector>
	</view>
</template>

<script>
	function _toConsumableArray(a) {
		if (Array.isArray(a)) {
			for (var t = 0, e = Array(a.length); t < a.length; t++) e[t] = a[t];

			return e;
		}

		return Array.from(a);
	}
	var app = getApp();
	import UniAddressSelector from '@/components/UniAddressSelector.vue';
	export default {
		data() {
			return {
				now_status: 1,
				isShow: !1,
				parent_uid: 0,
				is_ok: !1,
				banner: [],
				indicatorDots: !0,
				autoplay: !0,
				interval: 5e3,
				duration: 1e3,
				textJson: [],
				textIndex: 0,
				nav_choose: ["分类", "品牌", "年限", "公里数", "排序"],
				active_index: 0,
				sortArr: ["最新发布", "价格最低", "价格最高", "里程最少", "年龄最短", "距离最近"],
				km_arr: ["0~3万", "3~5万", "5~10万", "10~15万", "15~20万", "20~30万", "30~50万", "50万以上"],
				year_arr: ["全新车", "1~3年", "3~5年", "5~9年", "10年以上"],
				zl_arr: ['10吨以下', '10~20吨', '20~30吨', '30吨以上'],
				othClass: [],
				index: 0,
				fenlei_id: 0,
				pinpai_id: 0,
				nianxian_id: 0,
				km_id: 0,
				sort_id: 0,
				car_year: "",
				car_brand: "",
				car_km: "",
				car_class: "",
				search_arr: [],
				market: [],
				brand: [],
				check_name: "",
				carList: [],
				sort_show: !1,
				leftid: 1,
				show_new: !0,
				brand_show: !1,
				recom: 0,
				home_arr: [],
				brandname: "",
				selectbrand: "",
				brand_status: 0,
				plate_type: 1,
				scanReachBottom: !1,
				unitid: 123,
				latitude: 0,
				longitude: 0,
				region: ["", "", ""],
				customItem: "不限",
				area_set: 2,
				// 分类导航
				navData: [{
						id: 43,
						img: 'addons/monai_market/static/wimgs/n_01.png',
						name: '配件商城',
						type: 0
					}, {
						id: 37,
						img: 'addons/monai_market/static/wimgs/n_02.png',
						name: '二手挖机',
						type: 0
					}, {
						id: 41,
						img: 'addons/monai_market/static/wimgs/n_03.png',
						name: '二手汽车',
						type: 0
					}, {
						id: 42,
						img: 'addons/monai_market/static/wimgs/n_04.png',
						name: '破碎锤',
						type: 0
					}, {
						id: 44,
						img: 'addons/monai_market/static/wimgs/n_05.png',
						name: '货运通',
						type: 9
					},
					// {
					//      id: 44,
					//      img: 'addons/monai_market/static/wimgs/n_05.png',
					//      name: '顺风车',
					//      type: 3
					//    }, 
					{
						id: 45,
						img: 'addons/monai_market/static/wimgs/n_06.png',
						name: '矿山设备',
						type: 0
					}, {
						id: 38,
						img: 'addons/monai_market/static/wimgs/n_07.png',
						name: '装载机',
						type: 0
					}, {
						id: 8,
						img: 'addons/monai_market/static/wimgs/n_08.png',
						name: '找工作',
						type: 1
					}, {
						id: 46,
						img: 'addons/monai_market/static/wimgs/n_09.png',
						name: '出租求租',
						type: 0
					}, {
						id: 10,
						img: 'addons/monai_market/static/wimgs/n_10.png',
						name: '免费评估',
						type: 2
					}
				],
				// 买设备筛选条件
				condData: [{
					id: 1,
					name: '10万以下'
				}, {
					id: 2,
					name: '10-30万'
				}, {
					id: 3,
					name: '30-50万'
				}, {
					id: 4,
					name: '50万以上'
				}, {
					id: 5,
					name: '10吨以下'
				}, {
					id: 6,
					name: '10-20吨'
				}, {
					id: 7,
					name: '20-30吨'
				}, {
					id: 8,
					name: '30吨以上'
				}],
				//域名
				webUrl: '',
				hotList: [],
				newList: [],
				userInfo: null,
				isUser: 0,
				allClass: [],
				car_type: [],
				indexs: "",
				info_name: "",
				brandid: 0,
				showUniAddressSelector: false,
				areaInfoObj:{},
				areaInfo:[]
			};
		},

		components: {
			UniAddressSelector
		},
		props: {},
		onLoad: function(a) {
			this.refreshPage3389(a);
		},
		onReachBottom: function() {
			this.show_new && this.getNewList();
		},
		onPullDownRefresh: function() {
			var a = this;
			setTimeout(function() {
				wx.stopPullDownRefresh(), a.setData({
					is_ok: !1,
					banner: [],
					indicatorDots: !0,
					autoplay: !0,
					interval: 5e3,
					duration: 1e3,
					textJson: [],
					textIndex: 0,
					active_index: 0,
					index: 0,
					fenlei_id: 0,
					pinpai_id: 0,
					nianxian_id: 0,
					km_id: 0,
					sort_id: 0,
					market: [],
					brand: [],
					car_year: "",
					car_brand: "",
					car_km: "",
					car_class: "",
					search_arr: [],
					check_name: "",
					carList: [],
					sort_show: !1,
					leftid: 1,
					show_new: !0,
					brand_show: !1
				}), a.refreshPage3389({});
			}, 1500);
		},
		onShareAppMessage: function(a) {
			return {
				//title: this.data.info_name + "",
				title: '一个没有中介商的平台.二手设备买卖，配件批发零售，二手汽买卖，顺风车，出租求租',
				path: "/pages/index/index",
				//desc:'',
				success: function(a) {},
				fail: function(a) {}
			};
		},
		onShow: function() {
			var a = this; // var loc = wx.getStorageSync('loca');
			// if (loc) {

			a.check_status();
			var addr = wx.getStorageSync('addr');

			if (addr) { // a.setData({
				//   region: addr
				// });
			} // }


			if ("" != a.brandid && "" != a.brandname && 1 == a.brand_status) {
				app.globalData.imgUrl(), a.setData({
					webUrl: wx.getStorageSync('webUrl')
				});
				console.log('域名：', wx.getStorageSync('webUrl'));
				var t = a.brandname,
					e = a.brandid,
					i = "active_index2",
					n = {
						pinpai_id: e,
						car_brand: t,
						active_index: 2,
						mark: i,
						check_name: t
					},
					s = this.search_arr.filter(function(a) {
						return a.mark != i;
					});
				s.push(n), this.setData({
					is_ok: !1,
					car_brand: t,
					pinpai_id: e,
					search_arr: s,
					leftid: 1,
					show_new: !0,
					brand_show: !1,
					brandid: 0,
					brandname: ""
				}), this.listFun(1);
			}
		},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {
			var that = this;
			that.getNewList();
		},
		methods: {
			handleCancel() {
			    this.showUniAddressSelector = false;
			},
			handleConfirm(areaInfoObj) {
			    this.showUniAddressSelector = false;
			    this.areaInfoObj = areaInfoObj;
				this.areaInfo = areaInfoObj.fullAreaTextInitial.split(',')
				this.region = [areaInfoObj.provinceObj.value || '',areaInfoObj.cityObj.value || '',areaInfoObj.areaObj.value || '']
				this.getNewList(1);
				this.getHotList(1);
			},
			getPayment(price) {
				let num = Number(price) / 2
				return num.toFixed('2')
			},
			//获取首页所有分类
			getAllClass: function() {
				var that = this; // app.util.request({
				//   url: "entry/wxapp/Api",
				//   data: {
				//     m: "monai_market",
				//     r: "home.index.catelist",
				//   },
				//   success: function(res) {
				//     console.log('所有分类返回：', res.data);
				//     var arr = [];
				//     var tarr = res.data.data,
				//       jgarr = [{
				//         id: 0,
				//         name: "0~3万",
				//         type: 2
				//       }, {
				//         id: 1,
				//         name: "3~5万",
				//         type: 2
				//       }, {
				//         id: 2,
				//         name: "5~10万",
				//         type: 2
				//       }, {
				//         id: 3,
				//         name: "10~15万",
				//         type: 2
				//       }, {
				//         id: 4,
				//         name: "15~20万",
				//         type: 2
				//       }, {
				//         id: 5,
				//         name: "20~30万",
				//         type: 2
				//       }, {
				//         id: 6,
				//         name: "30~50万",
				//         type: 2
				//       }, {
				//         id: 7,
				//         name: "50万以上",
				//         type: 2
				//       }],
				//       yarr = [{
				//         id: 0,
				//         name: "全新车",
				//         type: 3
				//       }, {
				//         id: 1,
				//         name: "1~3年",
				//         type: 3
				//       }, {
				//         id: 2,
				//         name: "3~5年",
				//         type: 3
				//       }, {
				//         id: 3,
				//         name: "5~9年",
				//         type: 3
				//       }, {
				//         id: 4,
				//         name: "10年以上",
				//         type: 3
				//       }],
				// zlarr = [{
				//   id: 0,
				//   name: "10吨以下",
				//   type: 4
				// }, {
				//   id: 1,
				//   name: "10~20吨",
				//   type: 4
				// }, {
				//   id: 2,
				//   name: "20~30吨",
				//   type: 4
				// }, {
				//   id: 3,
				//   name: "30吨以上",
				//   type: 4
				// }];
				//     arr=arr.concat(tarr);
				//     console.log(jgarr);
				//     arr[2]=jgarr;
				//     arr[3]=yarr;
				//     arr[4]=zlarr;
				//     console.log(arr);
				//     that.setData({
				//       allClass: that.data.allClass.concat(arr)
				//     });
				//     console.log('allClass', that.data.allClass);
				//   },
				//   fail: function(res) {}
				// });

				var tarr = [
					[{
						id: 573,
						name: '卡特',
						type: 0
					}, {
						id: 572,
						name: '小松',
						type: 0
					}, {
						id: 574,
						name: '日立',
						type: 0
					}, {
						id: 575,
						name: '神钢',
						type: 0
					}, {
						id: 580,
						name: '斗山',
						type: 0
					}, {
						id: 577,
						name: '住友',
						type: 0
					}, {
						id: 585,
						name: '徐工',
						type: 0
					}, {
						id: 584,
						name: '三一',
						type: 0
					}],
					[{
						id: 38,
						name: '装载机',
						type: 1
					}, {
						id: 47,
						name: '压路机',
						type: 1
					}, {
						id: 40,
						name: '推土机',
						type: 1
					}, {
						id: 37,
						name: '挖掘机',
						type: 1
					}],
					[{
						id: 0,
						name: "10吨以下",
						type: 4
					}, {
						id: 1,
						name: "10~20吨",
						type: 4
					}, {
						id: 2,
						name: "20~30吨",
						type: 4
					}, {
						id: 3,
						name: "30吨以上",
						type: 4
					}]
				];
				that.setData({
					allClass: that.allClass.concat(tarr)
				});
			},
			check_status: function() {
				var that = this;
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.examine"
					},
					success: function(res) {
						console.log('状态', res.data); // 1 开 0 关

						that.setData({
							now_status: res.data.data
						});
					},
					fail: function(res) {}
				});
			},
			//查看某一个分类的详情
			toSeeDetList: function(e) {
				var that = this,
					id = e.currentTarget.dataset.id,
					name = e.currentTarget.dataset.name,
					type = e.currentTarget.dataset.type;
				console.log(id + '-----' + name + '-----' + type);
				wx.navigateTo({
					url: '/pagesA/productList/productList?cid=' + id + '&tname=' + name + '&otype=' + type
				});
			},
			//点击买卖设备按钮
			toMMPage: function(e) {
				var that = this,
					index = e.currentTarget.dataset.index;
				console.log(index);

				if (index == 0) {
					wx.switchTab({
						url: '/pages/indexR/indexR'
					});
				} else {
					wx.switchTab({
						url: '/pages/carSale/carSale'
					});
				}
			},
			getUser: function(e) {
				var t = this;
				console.log('用户信息：', e);
				t.setData({
					isUser: 0
				});
				app.globalData.util.getUserInfo(function(a) {
					console.log('getUserInfo:', a);
					a.memberInfo ? t.firstin(a.memberInfo) : t.setData({
						isShow: !0
					});
				});
			},
			qxsq_butt: function() {
				var that = this;
				that.setData({
					isUser: 0
				});
			},
			//获取热门机型
			getHotList: function(e) {
				var that = this;

				if (e == 1) {
					that.setData({
						hotList: []
					});
				}

				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.hot_carlist",
						// leftid: this.data.leftid,
						latitude: that.latitude,
						longitude: that.longitude,
						province: this.region[0],
						city: this.region[1],
						district: this.region[2]
					},
					success: function(res) {
						console.log('热门机型：', res.data);
						that.setData({
							hotList: res.data.data
						});
					},
					fail: function(res) {}
				});
			},
			//获取最新好车列表
			getNewList: function(e) {
				var that = this;

				if (e == 1) {
					that.setData({
						newList: [],
						leftid: 1
					});
				}

				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.new_carlist",
						leftid: that.leftid++,
						latitude: that.latitude,
						longitude: that.longitude,
						province: that.region[0],
						city: that.region[1],
						district: that.region[2]
					},
					success: function(res) {
						console.log('最新好车：', res.data); // that.setData({
						//   newList:res.data.data
						// });

						var t;
						0 < res.data.data.length ? ((t = that.newList).push.apply(t, _toConsumableArray(res
							.data.data)), that.setData({
							scanReachBottom: !1
						}), that.setData({
							is_ok: !1,
							newList: that.newList
						})) : (that.setData({
							scanReachBottom: !0
						}), that.show_new = !1);
					},
					fail: function(res) {}
				});
			},
			//点击头部分类
			click_topNav: function(e) {
				var ty = e.currentTarget.dataset.id,
					cid = e.currentTarget.dataset.cid,
					name = e.currentTarget.dataset.name,
					that = this;
				console.log(e.currentTarget.dataset.id);

				if (ty == 0) {
					uni.navigateTo({
						url: '/pagesA/tabber/a'
					})
					// wx.navigateTo({
					// 	url: '/pagesA/productList/productList?cid=' + cid + '&tname=' + name
					// });
				} else if (ty == 1) {
					if (that.now_status != 1) {
						wx.navigateTo({
							url: '/pagesA/joinUs/joinUs?wh=1'
						});
					}
				} else if (ty == 2) {
					if (that.now_status != 1) {
						wx.navigateTo({
							url: '/pagesA/joinUs/joinUs?wh=2'
						});
					}
				} else if (ty == 9) {
					uni.showToast({
						title: '暂未开放',
						icon: 'none'
					})
				} else {
					wx.navigateTo({
						url: '/pagesA/partList/partList?tid=1'
					});
				}
			},
			//暂时跳转详情页面
			click_toDET: function() {
				wx.switchTab({
					url: '/pages/indexR/indexR'
				});
			},
			// 切换地区
			bindRegionChange: function(a) {
				var that = this;
				var t = "不限" == a.detail.value[0] ? "" : a.detail.value[0],
					e = "不限" == a.detail.value[1] ? "" : a.detail.value[1],
					i = "不限" == a.detail.value[2] ? "" : a.detail.value[2];
				that.setData({
					region: [t, e, i]
				}), that.getNewList(1), that.getHotList(1); // wx.setStorageSync('addr', that.data.region);
			},
			hideDialog: function() {
				this.setData({
					isShow: !this.isShow
				});
			},
			updateUserInfo: function(a) {
				var t = this;
				app.globalData.util.getUserInfo(function(a) {
					t.hideDialog(), t.firstin(a.memberInfo);
				}, a.detail);
			},
			firstin: function(a) {
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "me.binding",
						uid: a.uid,
						head_image: a.avatar,
						nickname: a.nickname,
						parent_uid: this.parent_uid
					},
					success: function(a) {}
				});
			},
			info_setFun: function() {
				var t = this;
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.info_set"
					},
					cachetime: "0",
					success: function(a) {
						console.log('配置信息：', a.data), t.setData({
							// unitid: a.data.data.head_flow_id,
							area_set: a.data.data.area_set
						});
						console.log('area_set:', t.area_set);
					}
				});
			},
			noticeFun: function() {
				var t = this;
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.home1"
					},
					cachetime: "0",
					success: function(a) {
						console.log(a), a.data.data.info_name.name && wx.setNavigationBarTitle({
								title: a.data.data.info_name.name + ""
							}), 1 == a.data.data.info_name.recom && t.is_home(), 2 == a.data.data.info_name
							.plate_type && t.setData({
								plate_type: 2
							}), t.setData({
								banner: a.data.data.banner,
								market: a.data.data.market,
								brand: a.data.data.brand,
								textJson: a.data.data.notice,
								info_name: a.data.data.info_name.name,
								recom: a.data.data.info_name.recom
							});
					}
				});
			},
			ok: function() {
				this.setData({
					is_ok: !1
				});
			},
			bannerFun: function(a) {
				var t = app.globalData.getAttr(a, "id"),
					e = app.globalData.getAttr(a, "type");
				console.log(e), 4 == e ? wx.navigateTo({
					url: "/pages/mine/sale/index"
				}) : 5 == e ? wx.navigateTo({
					url: "/pagesA/enter/enter"
				}) : 6 == e || 0 != t && wx.navigateTo({
					url: "/pagesA/home/carMessage/carMessage?id=" + t
				});
			},
			market_class: function(a) {
				var t = app.globalData.getAttr(a, "active_index"),
					e = !1;
				this.active_index == t && (e = !(t = 0)), this.setData({
					car_type: this.market,
					brand_show: !1,
					sort_show: !1,
					active_index: t,
					show_new: e
				});
			},
			market_brand: function(a) {
				wx.navigateTo({
					url: "../selectscards/index"
				});
			},
			car_detail: function(a) {
				var t = !1,
					e = app.globalData.getAttr(a, "active_index");
				this.active_index == e && (t = !(e = 0)), this.setData({
					is_ok: !0,
					car_type: this.km_arr,
					sort_show: !1,
					show_new: t,
					brand_show: !1,
					active_index: e
				});
			},
			car_yer: function(a) {
				var t = app.globalData.getAttr(a, "active_index");
				this.active_index == t && (t = 0), this.setData({
					sort_show: !1,
					car_type: this.year_arr,
					active_index: t,
					show_new: !1,
					brand_show: !1
				});
			},
			carListFun: function(a) {
				var t = app.globalData.getAttr(a, "name"),
					e = app.globalData.getAttr(a, "id");

				if (1 == this.active_index) {
					var i = {
						fenlei_id: e,
						car_class: t,
						active_index: 1,
						mark: s = "active_index1",
						check_name: t
					};
					(r = this.search_arr.filter(function(a) {
						return a.mark != s;
					})).push(i), this.setData({
						car_class: t,
						fenlei_id: e,
						check_name: t,
						search_arr: r,
						leftid: 1,
						show_new: !0
					});
				} else if (2 == this.active_index) {
					t = app.globalData.getAttr(a, "name"), i = {
						pinpai_id: e = app.globalData.getAttr(a, "id"),
						car_brand: t,
						active_index: 2,
						mark: s = "active_index2",
						check_name: t
					};
					(r = this.search_arr.filter(function(a) {
						return a.mark != s;
					})).push(i), this.setData({
						is_ok: !1,
						car_brand: t,
						pinpai_id: e,
						search_arr: r,
						leftid: 1,
						show_new: !0,
						brand_show: !1
					});
				} else if (3 == this.active_index) {
					var n = app.globalData.getAttr(a, "year");
					i = {
						nianxian_id: e = app.globalData.getAttr(a, "index"),
						car_year: n,
						active_index: 3,
						mark: s = "active_index3",
						check_name: n
					};
					(r = this.search_arr.filter(function(a) {
						return a.mark != s;
					})).push(i), this.setData({
						is_ok: !1,
						car_year: n,
						nianxian_id: 1 + parseInt(e),
						search_arr: r,
						leftid: 1,
						show_new: !0
					});
				} else if (4 == this.active_index) {
					var s,
						r,
						d = app.globalData.getAttr(a, "km");
					i = {
						km_id: e = app.globalData.getAttr(a, "index"),
						car_km: d,
						active_index: 4,
						mark: s = "active_index4",
						check_name: d
					};
					(r = this.search_arr.filter(function(a) {
						return a.mark != s;
					})).push(i), this.setData({
						is_ok: !1,
						car_km: d,
						km_id: 1 + parseInt(e),
						search_arr: r,
						leftid: 1,
						show_new: !0
					});
				}

				this.listFun(1);
			},
			listFun: function(a) {
				var e = this;
				1 == a ? this.setData({
					carList: []
				}) : 2 == a && this.setData({
					carList: [],
					leftid: 1,
					show_new: !0
				}), this.setData({
					active_index: 0
				}), app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.carList",
						fenlei_id: this.fenlei_id,
						pinpai_id: this.pinpai_id,
						nianxian_id: this.nianxian_id,
						km_id: parseInt(this.km_id),
						sort_id: this.sort_id,
						leftid: this.leftid++,
						latitude: this.latitude,
						longitude: this.longitude,
						province: this.region[0],
						city: this.region[1],
						district: this.region[2]
					},
					cachetime: "0",
					success: function(a) {
						var t;
						0 < a.data.data.length ? ((t = e.carList).push.apply(t, _toConsumableArray(a.data
							.data)), e.setData({
							scanReachBottom: !1
						}), e.setData({
							is_ok: !1,
							carList: e.carList
						})) : (e.setData({
							scanReachBottom: !0
						}), e.show_new = !1);
					}
				});
			},
			clone: function(a) {
				var t = app.globalData.getAttr(a, "index"),
					e = this.search_arr;
				1 == e[t].active_index ? this.setData({
					fenlei_id: 0,
					check_name: ""
				}) : 2 == e[t].active_index ? this.setData({
					pinpai_id: 0,
					car_brand: ""
				}) : 3 == e[t].active_index ? (this.setData({
					nianxian_id: 0,
					car_year: ""
				}), this.nianxian_id = 0) : 4 == e[t].active_index && (this.setData({
					km_id: 0,
					car_km: ""
				}), this.km_id = 0), e.splice(t, 1), this.setData({
					search_arr: e,
					active_index: 0,
					leftid: 1
				}), this.listFun(2);
			},
			active_nav: function(a) {
				var t = app.globalData.getAttr(a, "active_index");
				console.log(t);
				this.active_index != t ? this.setData({
					sort_show: !0,
					show_new: !1,
					active_index: t,
					brand_show: !1
				}) : this.setData({
					sort_show: !1,
					active_index: 0,
					show_new: !1
				});
			},
			sort_car: function(a) {
				var t = app.globalData.getAttr(a, "index");
				if (this.setData({
						sort_show: !1,
						is_ok: !1
					}), 5 == t) return this.distanceSortFun(t), !1;
				this.setData({
					sort_id: t
				}), this.listFun(2);
			},
			distanceSortFun: function(t) {
				var e = this;
				if (e.setData({
						active_index: 0
					}), 0 !== e.latitude && 0 !== e.longitude) return e.setData({
					sort_id: t
				}), e.listFun(2), !1;
				wx.getLocation({
					type: "gcj02",
					success: function(a) {
						e.setData({
							latitude: a.latitude,
							longitude: a.longitude,
							sort_id: t
						}), e.listFun(2);
					},
					fail: function(a) {
						wx.openSetting({
							success: function(a) {
								a.authSetting["scope.userLocation"] ? wx.getLocation({
									type: "gcj02",
									success: function(a) {
										e.setData({
											latitude: a.latitude,
											longitude: a.longitude,
											sort_id: t
										}), e.listFun(2);
									}
								}) : wx.showModal({
									content: "您未授权获取当前位置无法使用距离排序！",
									showCancel: !1
								});
							}
						});
					}
				});
			},
			search: function() {
				wx.navigateTo({
					url: "/pagesA/home/searchShop/searchShop"
				});
			},
			previewImage: function(a) {
				var t = app.globalData.getAttr(a, "src"),
					e = app.globalData.getAttr(a, "index"),
					i = [],
					n = !0,
					s = !1,
					r = void 0;

				try {
					for (var d, o = this.carList[e].image[Symbol.iterator](); !(n = (d = o.next()).done); n = !0) {
						var c = d.value;
						i.push(c.img_patch);
					}
				} catch (a) {
					s = !0, r = a;
				} finally {
					try {
						!n && o.return && o.return();
					} finally {
						if (s) throw r;
					}
				}

				wx.previewImage({
					current: t,
					urls: i
				});
			},
			detile: function(a) {
				var t = app.globalData.getAttr(a, "id");
				wx.navigateTo({
					url: "/pagesA/home/carMessage/carMessage?id=" + t
				});
			},
			can_1: function() {
				this.setData({
					is_ok: !1,
					sort_show: !1,
					active_index: 0,
					show_new: !0,
					brand_show: !1
				});
			},
			info_notice: function() {
				wx.navigateTo({
					url: "/pagesA/dting/index"
				});
			},
			store: function(a) {
				var t = app.globalData.getAttr(a, "uid");
				wx.navigateTo({
					url: "../store/index?uid=" + t
				});
			},
			is_home: function() {
				var t = this;
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.is_home"
					},
					cachetime: "0",
					success: function(a) {
						0 < a.data.data.length && t.setData({
							home_arr: a.data.data
						});
					}
				});
			},
			guanggao: function() {
				console.log("sdkhfkj");
			},
			refreshPage3389: function(a) {
				var t = this;
				var uinfo = wx.getStorageSync('userInfo');

				if (!uinfo) {
					t.setData({
						isUser: 1
					});
				}

				console.log('用户信息：', uinfo);
				app.globalData.imgUrl(), t.setData({
					webUrl: wx.getStorageSync('webUrl')
				});
				console.log('域名：', wx.getStorageSync('webUrl'));
				t.getNewList(0);
				t.getAllClass();
				a && a.scene && t.setData({
						parent_uid: a.scene
					}) // , app.util.getUserInfo(function (a) {
					//   console.log('getUserInfo:', a);
					//   a.memberInfo ? t.firstin(a.memberInfo) : t.setData({
					//     isShow: !0
					//   });
					// })
					, wx.getLocation({
						type: "gcj02",
						success: function(a) {
							console.log('地理位置授权：', a);
							wx.setStorageSync('loca', a);
							var lat = a.latitude,
								lon = a.longitude;
							t.setData({
								latitude: a.latitude,
								longitude: a.longitude
							}); //获取地址信息

							app.globalData.util.request({
								url: "entry/wxapp/Api",
								data: {
									m: "monai_market",
									r: "home.index.get_area",
									lat: lat,
									lng: lon
								},
								success: function(res) {
									console.log('地理位置返回：', res.data);
									app.globalData.imgUrl(), t.setData({
										webUrl: wx.getStorageSync('webUrl')
									});
									console.log('域名：', wx.getStorageSync(
										'webUrl')); // wx.setStorageSync('addr', res.data.data)
									// t.setData({
									//   region: [res.data.data[0], res.data.data[1], res.data.data[2]]
									// })

									t.getNewList(1);
								},
								fail: function(res) {}
							});
						},
						fail: function(a) {
							console.log('地理位置未授权：', a);
							app.globalData.imgUrl(), t.setData({
								webUrl: wx.getStorageSync('webUrl')
							});
							t.getNewList(0);
							console.log('域名：', wx.getStorageSync('webUrl'));
							wx.openSetting({
								success: function(a) {
									a.authSetting["scope.userLocation"] ? wx.getLocation({
										type: "gcj02",
										success: function(a) {
											//获取地址信息
											app.globalData.util.request({
												url: "entry/wxapp/Api",
												data: {
													m: "monai_market",
													r: "home.index.get_area",
													lat: lat,
													lng: lon
												},
												success: function(res) {
													console.log('地理位置返回：',
														res.data);
													app.globalData
														.imgUrl(), t
														.setData({
															webUrl: wx
																.getStorageSync(
																	'webUrl'
																)
														});
													console.log('域名：', wx
														.getStorageSync(
															'webUrl')
													); // t.setData({
													//   region: [res.data.data[0], res.data.data[1], res.data.data[2]]
													// })
												},
												fail: function(res) {}
											});
											t.setData({
												latitude: a.latitude,
												longitude: a.longitude
											}), t.getNewList(1);
										}
									}) : (wx.showModal({
										content: "您未授权获取当前位置无法进行地区筛选！",
										showCancel: !1
									}), t.getNewList(1)); // t._list(0));
								}
							});
						}
					}), this.noticeFun(), this.info_setFun(0), this.getHotList();
				setTimeout(function() {
					console.log('是否授权：', app.globalData.data.is_sq);
					console.log(app.globalData
						.userInfo
					); // if (app.userInfo) { //获取用户信息是一个异步操作，在onLoad函数加载的时候app.js中的onLaunch可能还没有加载，所以需要判断是否获取成功
					//   console.log('globalData1');
					//   this.setData({
					//     userInfo: app.userInfo,
					//     hasUserInfo: true
					//   })
					// } else if (this.data.canIUser) { //判断canIUser的值是否为true，实则在判断微信小程序版本是否支持相关属性 
					//   console.log('globalData2');
					//   app.userInfoReadyCallback = (res) => { // userInfoReadyCallback：userInfo的回调函数，声明一个回调函数，将回调函数传给app.js，
					//     //userInfo加载完成后会执行这个回调函数，这个回调函数会将获取的getUserInfo的结果直接传回来
					//     // 在app.js中获取用户信息之后调用这个函数，结果放在函数的参数中
					//     this.setData({
					//       userInfo: res.userInfo,
					//       hasUserInfo: true
					//     })
					//   }
					// } else {
					//   console.log('globalData3');
					//   wx.getUserInfo({ //在老的版本中是可以直接调用授权接口并获取用户信息
					//     success: (res) => {
					//       this.setData({
					//         userInfo: res.userInfo,
					//         hasUserInfo: true
					//       })
					//     }
					//   })
					//   console.log(t.data.userInfo,t.data.hasUserInfo);
					// }
				}, 200);
			}
		}
	};
</script>
<style>
	@import "./index.css";
</style>
